package icasue.runninginvoke.api;

import icasue.tools.compile.utils.DCUtil;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Author: Qiao Hang
 * @CreateDate: 2020/12/7 下午4:57
 * @UpdateDate:
 * @Description:
 */
@RestController
@RequestMapping("/dynamic-compile")
public class DynamicCodeLoadApi {

    @PostMapping(value = "/loadSourceCode",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Boolean loadSourceCode(@RequestPart("file") MultipartFile file) throws Throwable{
        Boolean result = DCUtil.loadSourceCode(file.getInputStream());
        return result;
    }

}
